module ew {
    export class MathHelper {
        public static Pi = Math.PI;
        public static PiOver2 = Math.PI / 2;
        public static PiOver4 = Math.PI / 4;
        public static PiOver180 = Math.PI / 180;
        public static TwoPi = 2 * Math.PI;

        public static clamp(value: number, min: number, max: number): number {
            if (value > max) 
                return max;
            if (value < min)
                return min;

            return value;
        }

        public static lerp(value1: number, value2: number, amount: number): number {
            return value1 + (value2 - value1) * amount;
        }

        public static toDegrees(radians: number): number {
            return radians * 180 / MathHelper.Pi;
        }

        public static toRadians(degrees: number): number {
            return degrees * MathHelper.Pi / 180;
        }

        public static randomInInterval(right: number): number;
        public static randomInInterval(left: number, right: number): number;

        public static randomInInterval(left?: number, right?: number): number {
            if (right == undefined)
                return -Math.random() * (2 * left) + left;

            return left + Math.random() * right;
        }
    }
}